package com.motong.gongdan.enums;

public enum WorkOrderState {
    NOT_BEGIN(0,"未开始"),
    EXECUTING(1,"执行中"),
    END(2,"已结束"),
    CANCEL(3,"已取消");
    private Integer code;
    private String description;

    WorkOrderState(Integer code,String description) {
        this.code = code;
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public Integer getCode() {
        return code;
    }

    public static Integer getCodeByDesc(String desc) {
        WorkOrderState[] workOrderStates = values();
        for (WorkOrderState workOrderState : workOrderStates) {
            if (workOrderState.getDescription().equals(desc)) {
                return workOrderState.getCode();
            }
        }
        return null;
    }

    public static String getDescByCode(Integer code) {
        WorkOrderState[] workOrderStates = values();
        for (WorkOrderState workOrderState : workOrderStates) {
            if (workOrderState.getCode().equals(code)) {
                return workOrderState.getDescription();
            }
        }
        return null;
    }


}
